package vell.velllock.util;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class FileUtil {
	public static void copyFile(InputStream myInput, OutputStream myOutput) throws IOException{
		//transfer bytes from the InputStream to the OutputStream
    	byte[] buffer = new byte[1024];
    	int length;
    	while ((length = myInput.read(buffer))>0){
    		myOutput.write(buffer, 0, length);
    	}
    	myOutput.flush();
    	
    	//Close the streams
    	myOutput.close();
    	myInput.close();
	}
	
	public static void createFile(File file) throws IOException{
		if(file.getParentFile().exists() == false){
			file.getParentFile().mkdirs();
		}
		file.createNewFile();
	}
}
